import { NextFunction, Request, Response } from 'express';
import { Container } from 'typedi';
import { JydraftscomService } from '@services/jydraftscom.service';
import * as console from 'console';

export class JydraftsController {
  public draftService = Container.get(JydraftscomService);

  public createDrat = async (req: Request, res: Response, next: NextFunction): Promise<void> => {
    try {
      const msg: string = await this.draftService.getTstDraftMsg();

      console.log('--------', msg);
      const dftCon = await this.draftService.getDraft();
      console.log('--------', dftCon);
      await this.draftService.addText(dftCon, msg);
      await this.draftService.saveDft(dftCon, './output');

      res.status(200).json({ data: msg, message: 'getmst' });
    } catch (error) {
      next(error);
    }
  };
}
